package com.jt.system.dao.impl;

import com.jt.system.dao.UserMapper;
import com.jt.system.pojo.User;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

/**
 * 数据层实现类对象
 * 这个是mapper的实现类底层，在框架中会自动生成
 * SqlSessionTemplate是核心底层*/
@Repository
public class DefaultUserMapperImpl{
    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;
    public User selectUserByUsername(String username){
        String namespace = "com.jt.system.dao.UserMapper";
        String elementId = "selectUserByUsername";
        String statement = String.format("%s.%s", namespace,elementId);
        return sqlSessionTemplate.selectOne(statement,username);
    }
}
